##
## Makefile
##
## Made by vincent leroy
## Login   leroy_v<@epitech.eu>
##
## Started on  Wed Jan 30 20:55:09 2013 vincent leroy
## Last update Wed Feb 06 17:27:44 2013 vincent leroy
##

SRC	= malloc.c \
	  bsr.c \
	  my_putaddr.c \
	  my_putnbr.c \
	  accesseur.c \
	  free.c

NAME	= libmy_malloc_$(shell arch).so

REALNAME	= libmy_malloc.so

FLAG	= -Wall -Wextra -Werror -W -std=gnu99 -lpthread

FLAGLIB	= -fPIC $(FLAG)
FLAGLIB	+= -g

CFLAGS	= $(FLAG)

LDFLAGS	= $(FLAG) ./$(REALNAME)

OBJ	= $(SRC:.c=.o)

NAMETEST	= test

SRCTEST	= simple_test.c

OBJTEST	= $(SRCTEST:.c=.o)

RM	= rm -f

CC	= gcc

all: $(NAME) $(NAMETEST)

$(NAME):
	$(CC) -c $(SRC) $(FLAGLIB)
	ld -G $(OBJ) -o $(NAME)
	ln -fs $(NAME) $(REALNAME)

$(NAMETEST):	$(OBJTEST)
	$(CC) $(OBJTEST) -o $(NAMETEST) $(LDFLAGS)

clean:
	$(RM) $(OBJ) $(OBJTEST) *.swp *~ *#

fclean: clean
	$(RM) $(NAME)
	$(RM) $(NAMETEST)
	$(RM) $(REALNAME)

re: fclean all

.PHONY: all clean fclean re
